<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Start_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-start_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[start_time]" type="text" value="{$row.start_time}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('End_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-end_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[end_time]" type="text" value="{$row.end_time}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('添加日程')}:</label>
        <div class="col-xs-12 col-sm-8">
            <dl class="fieldlist" data-name="row[item]"  data-template="fieldtpl">
                <dd>
                    <ins style="width:20%">{:__('周几')}</ins>
                    <ins style="width:20%">{:__('第几节')}</ins>
                    <ins style="width:20%">{:__('选择科目')}</ins>
                    <!--                    <ins style="width:20%">{:__('科目')}</ins>-->
                </dd>
                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
                <textarea name="row[item]"  class="form-control hide" cols="30" rows="5">{$item_arr}</textarea>
            </dl>
        </div>
    </div>
    <script type="text/html" id="fieldtpl">
        <dd class="form-inline">
            <select class="form-control selectpage" name="<%=name%>[<%=index%>][week]" style="width:20%">
                <option value="1" <%if(row.week==1){%>selected<%}%> >周一</option>
                <option value="2" <%if(row.week==2){%>selected<%}%> >周二</option>
                <option value="3" <%if(row.week==3){%>selected<%}%> >周三</option>
                <option value="4" <%if(row.week==4){%>selected<%}%> >周四</option>
                <option value="5" <%if(row.week==5){%>selected<%}%> >周五</option>
            </select>
            <select class="form-control selectpage" name="<%=name%>[<%=index%>][node]" style="width:20%">
                <option value="1" <%if(row.node==1){%>selected<%}%> >1</option>
                <option value="2" <%if(row.node==2){%>selected<%}%>  >2</option>
                <option value="3" <%if(row.node==3){%>selected<%}%>  >3</option>
                <option value="4" <%if(row.node==4){%>selected<%}%>  >4</option>
                <option value="5" <%if(row.node==5){%>selected<%}%>  >5</option>
                <option value="6" <%if(row.node==6){%>selected<%}%>  >6</option>
            </select>
            <select class="form-control selectpage" name="<%=name%>[<%=index%>][type]" data-number="<%=index%>" style="width:20%" onchange="subject(this)">
                <option value="1"  <%if(row.type==1){%>selected<%}%>  >主科</option>
                <option value="2" <%if(row.type==2){%>selected<%}%>  >科任</option>
                <option value="3" <%if(row.type==3){%>selected<%}%>  >班队会</option>
            </select>
                <select class="form-control selectpage subject1" name="<%=name%>[<%=index%>][subject_id1]" <%if(row.type==2 || row.type==3){%> style="display:none;width:20%" <%}%> style="width:20%">
                    <option value="">请选择</option>
                    {foreach name="subject1" id="item"}
                    <option value="{$item.id}" <%if(row.subject_id=={$item.id}){%>selected<%}%> >{$item.name}</option>
                    {/foreach}
                </select>
            <select class="form-control selectpage subject2" name="<%=name%>[<%=index%>][subject_id2]" <%if(row.type!=2){%> style="display:none;width:20%" <%}%> style="width:20%">
                <option value="">请选择</option>
                {foreach name="subject2" id="item"}
                <option value="{$item.id}"  <%if(row.subject_id=={$item.id}){%>selected<%}%> >{$item.name}</option>
                {/foreach}
            </select>

            <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
        </dd>
    </script>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script>
    function subject(data) {
        var type = $(data).val();
        if(type==1){
            $(data).next().next(".subject2").hide();
            $(data).next(".subject1").show();
        }else if(type==2){
            $(data).next().next(".subject2").show();
            $(data).next(".subject1").hide();
        }else if(type==3){
            $(data).next().next(".subject2").hide();
            $(data).next(".subject1").hide();
        }
    }
</script>